
from JNumeric import *;
from cern.colt.matrix import *
from cern.colt.matrix.impl import *

def JNToColt(ja):
     nAxes = len(ja.shape)
     if nAxes not in (1,2,3):
         raise ValueError, "Colt only supports 1, 2 and 3 dimensional arrays"
     constructor = [DenseDoubleMatrix1D, DenseDoubleMatrix2D,
                 DenseDoubleMatrix3D][nAxes-1]
     return constructor(ja)
 
def ColtToJn(ca):
     return DenseDoubleMatrix1D(ca.like1D(ca.size()));
     